﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Outpatient.Migrations
{
    /// <inheritdoc />
    public partial class add_table_OtpRxRec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "OtpRxRec",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpMdtrtRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    Rxno = table.Column<string>(type: "text", nullable: false),
                    OtpRxTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    BeginDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    BilgDeptId = table.Column<Guid>(type: "uuid", nullable: false),
                    BilgDeptName = table.Column<string>(type: "text", nullable: false),
                    BilgDrId = table.Column<Guid>(type: "uuid", nullable: false),
                    BilgDrCodg = table.Column<string>(type: "text", nullable: false),
                    BilgDrName = table.Column<string>(type: "text", nullable: false),
                    ChkDrCodg = table.Column<string>(type: "text", nullable: true),
                    ChkDrName = table.Column<string>(type: "text", nullable: true),
                    ChkTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    Expy = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    RxStats = table.Column<int>(type: "integer", nullable: false),
                    HospApprFlag = table.Column<bool>(type: "boolean", nullable: false),
                    RxCircFlag = table.Column<bool>(type: "boolean", nullable: false),
                    DiseCodg = table.Column<string>(type: "text", nullable: true),
                    RxTotAmt = table.Column<decimal>(type: "numeric", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpRxRec", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpRxRec_OtpMdtrtRec_OtpMdtrtRecId",
                        column: x => x.OtpMdtrtRecId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpMdtrtRec",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_OtpRxRec_OtpRxType_OtpRxTypeId",
                        column: x => x.OtpRxTypeId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpRxType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "OtpRxRecDetl",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpRxRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    PubItemId = table.Column<Guid>(type: "uuid", nullable: false),
                    DrordName = table.Column<string>(type: "text", nullable: false),
                    DrordNote = table.Column<string>(type: "text", nullable: false),
                    Grpno = table.Column<string>(type: "text", nullable: false),
                    Pric = table.Column<decimal>(type: "numeric", nullable: false),
                    DrugMedcWayId = table.Column<string>(type: "text", nullable: false),
                    DrugMedcWayCodg = table.Column<string>(type: "text", nullable: false),
                    DrugMedcWayName = table.Column<string>(type: "text", nullable: false),
                    UsedFrquId = table.Column<Guid>(type: "uuid", nullable: false),
                    UsedFrquCodg = table.Column<string>(type: "text", nullable: false),
                    UsedFrquName = table.Column<string>(type: "text", nullable: false),
                    DrugUsedSdose = table.Column<decimal>(type: "numeric", nullable: false),
                    DrugUsedDosuntCode = table.Column<string>(type: "text", nullable: false),
                    DrugUsedDosuntName = table.Column<string>(type: "text", nullable: false),
                    MedcDays = table.Column<int>(type: "integer", nullable: false),
                    DrugDosformId = table.Column<Guid>(type: "uuid", nullable: false),
                    DrugDosformName = table.Column<string>(type: "text", nullable: false),
                    DrugSpec = table.Column<string>(type: "text", nullable: false),
                    DismedCnt = table.Column<decimal>(type: "numeric", nullable: false),
                    drugUsedIdose = table.Column<decimal>(type: "numeric", nullable: false),
                    TotAmt = table.Column<decimal>(type: "numeric", nullable: false),
                    SkintstDicmCode = table.Column<string>(type: "text", nullable: false),
                    SkintstDicmName = table.Column<string>(type: "text", nullable: false),
                    BeginDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    AcordDeptId = table.Column<Guid>(type: "uuid", nullable: true),
                    AcordDeptCodg = table.Column<string>(type: "text", nullable: true),
                    AcordDeptName = table.Column<string>(type: "text", nullable: true),
                    AcordDrId = table.Column<Guid>(type: "uuid", nullable: true),
                    AcordDrCodg = table.Column<string>(type: "text", nullable: true),
                    AcordDrName = table.Column<string>(type: "text", nullable: true),
                    TcmdrugUsedWay = table.Column<string>(type: "text", nullable: true),
                    EtipFlag = table.Column<bool>(type: "boolean", nullable: false),
                    EtipHospCode = table.Column<string>(type: "text", nullable: true),
                    DscgTkdrugFlag = table.Column<bool>(type: "boolean", nullable: false),
                    MatnFeeFlag = table.Column<bool>(type: "boolean", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpRxRecDetl", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpRxRecDetl_OtpRxRec_OtpRxRecId",
                        column: x => x.OtpRxRecId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpRxRec",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OtpRxRec_OtpMdtrtRecId",
                schema: "Outpatient",
                table: "OtpRxRec",
                column: "OtpMdtrtRecId");

            migrationBuilder.CreateIndex(
                name: "IX_OtpRxRec_OtpRxTypeId",
                schema: "Outpatient",
                table: "OtpRxRec",
                column: "OtpRxTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_OtpRxRecDetl_OtpRxRecId",
                schema: "Outpatient",
                table: "OtpRxRecDetl",
                column: "OtpRxRecId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OtpRxRecDetl",
                schema: "Outpatient");

            migrationBuilder.DropTable(
                name: "OtpRxRec",
                schema: "Outpatient");
        }
    }
}
